
<%@ include file="../common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script type="text/javascript">
	$(document).ready(
		function() {
			$("#saveCompany").attr("action",
					'<c:url value="/saveCompany.htm"></c:url>');
			$("#companyName").focus();
			enableDisableSelectCompany('id');
			var formState = '<c:out value="${formState}"></c:out>';
			if(formState == 'new_form')
				resetForm('saveCompany');
		}
	);
</script>

<div align="left">
 
<label class="formLabel"> ${successMessage} </label>
<c:if test="${errorCount gt 0}">
	<label class="errorMsg formLabel"> There are some errors in screen.</label>
</c:if>
</div>

<br/>
<div>
	<form:form commandName="companyDetailsDTO" id="saveCompany"	name="saveCompany">
		<form:hidden path="child"/>
			<table class="adminFilterTable">
				<tr class="tableChildHeaderColor">
					<td colspan="6" align="center">ADD NEW COMPANY</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"><form:label path="companyType"> Company Type * </form:label></td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel" align="left">
						<table>
							<tr align="left">
								<td>
									<form:input path="companyType" type="radio" id="groupCompany" name="companySetup" value="GroupHead" onclick="enableDisableSelectCompany('groupCompany');"/>Group Head Company
								</td>
							</tr>
							<tr align="left">
								<td>
									<c:if test="${!(fn:length(parentCompaniesList) eq 0)}">
									<form:input path="companyType" type="radio"
										id="subsidiaryCompany" name="companySetup" value="Subsidiary"
										onclick="enableDisableSelectCompany('subsidiaryCompany');" />Subsidiary Company
									</c:if>
								</td>
							</tr>
							<tr align="left">
								<td>
									<form:input path="companyType" type="radio" id="standAloneCompany" name="companySetup" value="StandAlone" onclick="enableDisableSelectCompany('standAloneCompany');"/>Stand Alone Company
								</td>
							</tr>
						</table>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">
						<form:errors cssClass="errorMessage" path="companyType"></form:errors>
					</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">Select Subsidiary Company</td>
					<td class="spacingColumnWidthLess"></td>
					<td>
						<form:select path="parentId" cssClass="disableInputField">
							<c:forEach items="${parentCompaniesList}" var="parentCompany">
							<form:option value="${parentCompany.cdId}">${parentCompany.cdName}</form:option>
							</c:forEach>
						</form:select>					
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">Name*</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:input path="cdName" id="companyName"></form:input>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">
						<form:errors cssClass="errorMessage" path="cdName"></form:errors>
					</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">Code*</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:input path="cdCode"></form:input> 
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">
						<form:errors cssClass="errorMessage" path="cdCode"></form:errors>
					</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">Address</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:input path="address"></form:input>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">State</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:select path="cdState" id="state"
							onchange="loadBelowValues(this.id,'district');">
						<form:option value="">Choose State</form:option>
							<c:forEach var="stateSet" items="${stateSet}">
								<form:option value="${stateSet}">${stateSet}</form:option>
							</c:forEach>
						</form:select>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">District</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:select path="cdDistrict" id="district"
							onchange="loadBelowValues(this.id,'city');"></form:select>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>	
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel">City</td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField">
						<form:select path="cdCity" id="city"></form:select>
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
					<td class="spacingColumnWidthLess"></td>
					<td align="left">
						<input class="formButton ui-corner-all" type="button" value="SAVE" onclick="javascript:addEntity('saveCompany')">
					</td>
					<td class="spacingColumnWidthLess"></td>
					<td></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
			</table>
		</form:form>
	</div>
	